﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

/// <summary>
/// Summary description for clsEducationDAL
/// </summary>
public class clsEducationDAL
{
    InstantNaukriDataContextDataContext objInstantNaukriDataContextDataContext = new InstantNaukriDataContextDataContext();
 
	public clsEducationDAL()
	{
		//
		// TODO: Add constructor logic here
		//
	}


    public List<IN_TB_EDUCATION> GetAllEducationDegree()
    {
        try
        {
            List<IN_TB_EDUCATION> objIN_TB_EDUCATION = new List<IN_TB_EDUCATION>();
            objIN_TB_EDUCATION = (from obj in objInstantNaukriDataContextDataContext.IN_TB_EDUCATIONs
                                 select obj).ToList();
            return objIN_TB_EDUCATION;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public IN_TB_EDUCATION GetAllEducationDegreeById(int Id)
    {
        try
        {
            IN_TB_EDUCATION objIN_TB_EDUCATION = new IN_TB_EDUCATION();
            objIN_TB_EDUCATION = (from obj in objInstantNaukriDataContextDataContext.IN_TB_EDUCATIONs
                                 where obj.ID == Id
                                 select obj).SingleOrDefault();
            return objIN_TB_EDUCATION;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public int SaveEducationDegreeMst(IN_TB_EDUCATION objIN_TB_EDUCATION)
    {
        try
        {
            IN_TB_EDUCATION objIN_TB_EDUCATIOND = new IN_TB_EDUCATION();
            objIN_TB_EDUCATIOND = (from obj in objInstantNaukriDataContextDataContext.IN_TB_EDUCATIONs
                                  where obj.ID == objIN_TB_EDUCATION.ID
                                  select obj).SingleOrDefault();
            if (objIN_TB_EDUCATIOND != null)
            {
                objIN_TB_EDUCATIOND.ID = objIN_TB_EDUCATION.ID;
                objIN_TB_EDUCATIOND.DEGREE = objIN_TB_EDUCATION.DEGREE;
                objIN_TB_EDUCATIOND.CREATED_BY = objIN_TB_EDUCATION.CREATED_BY;
                objIN_TB_EDUCATIOND.CREATED_ON = objIN_TB_EDUCATION.CREATED_ON;
                objIN_TB_EDUCATIOND.MODIFIED_BY = objIN_TB_EDUCATION.MODIFIED_BY;
                objIN_TB_EDUCATIOND.MODIFIED_ON = objIN_TB_EDUCATION.MODIFIED_ON;

                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_EDUCATION.ID;
            }
            else
            {
                objInstantNaukriDataContextDataContext.IN_TB_EDUCATIONs.InsertOnSubmit(objIN_TB_EDUCATION);
                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_EDUCATION.ID;
            }
        }
        catch (Exception)
        {

            throw;
        }
    }
    public void DeleteEducationDegree(int Degree_Id)
    {
        try
        {
            IN_TB_EDUCATION objIN_TB_EDUCATION = new IN_TB_EDUCATION();
            objIN_TB_EDUCATION = (from obj in objInstantNaukriDataContextDataContext.IN_TB_EDUCATIONs
                                  where obj.ID == Degree_Id
                                 select obj).SingleOrDefault();
            if (objIN_TB_EDUCATION != null)
            {
                objInstantNaukriDataContextDataContext.IN_TB_EDUCATIONs.DeleteOnSubmit(objIN_TB_EDUCATION);
                objInstantNaukriDataContextDataContext.SubmitChanges();
            }

        }
        catch (Exception)
        {

            throw;
        }
    }
}
